package com.CityHunter.OverLay;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.RectF;
import android.graphics.Paint.Style;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class MapOl extends Overlay {

	String name = "You";
	GeoPoint gp;

	public MapOl(GeoPoint gp) {

		this.gp = gp;
	}

	@Override
	public void draw(Canvas canvas, MapView mv, boolean shadow) {

		super.draw(canvas, mv, shadow);

		Paint p = new Paint();
		int[] scoords = new int[2];
		int sz = 5;

		Point myScreenCoords = new Point();
		mv.getProjection().toPixels(gp, myScreenCoords);

		// Draw point caption and its bounding rectangle
		scoords[0] = myScreenCoords.x;
		scoords[1] = myScreenCoords.y;
		p.setTextSize(14);
		p.setAntiAlias(true);

		int sw = (int) (p.measureText(name) + 0.5f);
		int sh = 25;
		int sx = scoords[0] - sw / 2 - 5;
		int sy = scoords[1] - sh - sz - 2;
		RectF rec = new RectF(sx, sy, sx + sw + 10, sy + sh);

		p.setStyle(Style.FILL);
		p.setARGB(128, 255, 0, 0);

		canvas.drawRoundRect(rec, 5, 5, p);

		p.setStyle(Style.STROKE);
		p.setARGB(255, 255, 255, 255);
		canvas.drawRoundRect(rec, 5, 5, p);
		// canvas.d

		canvas.drawText(name, sx + 5, sy + sh - 8, p);

		// Draw point body and outer ring
		p.setStyle(Style.FILL);
		p.setARGB(88, 255, 0, 0);
		p.setStrokeWidth(1);
		RectF spot = new RectF(scoords[0] - sz, scoords[1] + sz, scoords[0]
				+ sz, scoords[1] - sz);
		canvas.drawOval(spot, p);

		p.setARGB(255, 255, 0, 0);
		p.setStyle(Style.STROKE);
		canvas.drawCircle(scoords[0], scoords[1], sz, p);

	}
}
